package cn.edu.ctgu.ch2;

import reactor.core.publisher.Flux;

import java.time.Duration;

/**
 * 响应式编程
 *
 * @author tiger54910
 * @create 2025/2/3 10:38
 */
public class ReactorCode {
    public static Flux<Integer> sumElementsWithinTimeWindow(Flux<Integer> flux) {
        return flux.window(Duration.ofSeconds(10)).flatMap(window -> window.reduce(Integer::sum));
    }
}
